(function(){if(window.BX.CImageView)return;BX.viewImage=function(t,i,e,s,r){r=r||{};r.cycle=false;r.list=[{image:t,height:e,width:i,title:s}];var h=new BX.CImageView(r);h.show();return h};BX.viewImageBind=function(i,e,s,r){var h=new BX.CImageView(e);if(!s)s={tag:"IMG"};BX.ready(function(){t(i,s,r,h)});return h};function t(t,i,e,s){var t=BX(t);if(!!t){BX.bindDelegate(t,"click",i,function(r){var h=t;if(!!e){h=BX.findParent(this,e,t)||h}var a=BX.findChildren(h,i,true),l=[],n=false;for(var o=0;o<a.length;o++){var p={thumb:a[o].src,image:a[o].getAttribute("data-bx-image"),width:a[o].getAttribute("data-bx-width"),height:a[o].getAttribute("data-bx-height"),full:a[o].getAttribute("data-bx-full"),full_width:a[o].getAttribute("data-bx-full-width"),full_height:a[o].getAttribute("data-bx-full-height"),full_size:a[o].getAttribute("data-bx-full-size"),title:a[o].getAttribute("data-bx-title")||a[o].alt||a[o].title};var d=a[o].parentNode.tagName.toUpperCase()=="A"&&!!a[o].parentNode.href;if(d){p.image=p.image||a[o].parentNode.href;p.title=p.title||a[o].parentNode.title;p.width=a[o].parentNode.getAttribute("data-bx-width");p.height=a[o].parentNode.getAttribute("data-bx-height");p.full=p.full||a[o].parentNode.getAttribute("data-bx-full");if(!!p.full){p.full_width=p.full_width||a[o].parentNode.getAttribute("data-bx-full-width");p.full_height=p.full_height||a[o].parentNode.getAttribute("data-bx-full-height");p.full_size=p.full_size||a[o].parentNode.getAttribute("data-bx-full-size")}p.title=p.title||a[o].parentNode.getAttribute("data-bx-title")||a[o].parentNode.alt||a[o].parentNode.title}p.image=p.image||p.thumb;if(a[o]==this)n=p.image;if(!!p.image)l.push(p)}var c=this.parentNode.tagName.toUpperCase()=="A"&&!!this.parentNode.href,u=c&&!!n&&this.parentNode.href!=n;if(!u){s.setList(l);s.show(this.getAttribute("data-bx-image")||this.src);if(c)return BX.PreventDefault(r)}})}}BX.CImageView=function(t){this.params=BX.clone(BX.CImageView.defaultSettings);for(var i in t){this.params[i]=t[i]}this.DIV=null;this.OVERLAY=null;this.IMAGE_WRAP=null;this.IMAGE=BX.create("IMG",{props:{className:"bx-images-viewer-image"},events:{load:BX.proxy(this.adjustPos,this),click:BX.proxy(this.next,this)}});this.list=this.params.list;this.list_preload=[];this._current=0;this.bVisible=false};BX.CImageView.defaultSettings={list:[],cycle:true,resize:"WH",resizeToggle:false,showTitle:true,preload:1,minMargin:20,minPadding:12,lockScroll:false,keyMap:{27:"close",33:"prev",37:"prev",38:"prev",34:"next",39:"next",40:"next",32:"next"}};BX.CImageView.prototype._create=function(){if(!this.DIV){var t=BX.browser.IsIE()&&!BX.browser.IsDoctype()?"A":"SPAN",i=t=="A"?"javascript:void(0)":null;this.OVERLAY=document.body.appendChild(BX.create("DIV",{props:{className:"bx-images-viewer-overlay"},events:{click:BX.proxy(this._hide,this)}}));this.DIV=this.OVERLAY.appendChild(BX.create("DIV",{props:{className:"bx-images-viewer-wrap-outer"},events:{click:BX.eventCancelBubble},children:[this.PREV_LINK=BX.create(t,{props:{className:"bx-images-viewer-prev-outer",href:i},events:{click:BX.proxy(this.prev,this)},html:'<span class="bx-images-viewer-prev"></span>'}),this.NEXT_LINK=BX.create(t,{props:{className:"bx-images-viewer-next-outer",href:i},events:{click:BX.proxy(this.next,this)},html:'<span class="bx-images-viewer-next"></span>'}),this.IMAGE_TITLE=BX.create("DIV",{style:{bottom:"0"},props:{className:"bx-images-viewer-title"}}),BX.create("DIV",{props:{className:"bx-images-viewer-wrap-inner"},style:{padding:this.params.minPadding+"px"},children:[this.IMAGE_WRAP=BX.create("DIV",{props:{className:"bx-images-viewer-wrap"},children:[this.IMAGE]})]}),BX.create(t,{props:{className:"bx-images-viewer-close",href:i},events:{click:BX.proxy(this._hide,this)},html:'<span class="bx-images-viewer-close-inner"></span>'})]}));if(!!this.params.resizeToggle){this.IMAGE_WRAP.appendChild(BX.create("SPAN",{props:{className:"bx-images-viewer-size-toggle"},style:{right:this.params.minPadding+"px",bottom:this.params.minPadding+"px"},events:{click:BX.proxy(this._toggle_resize,this)}}))}}};BX.CImageView.prototype._keypress=function(t){var i=(t||window.event).keyCode||(t||window.event).charCode;if(!!this.params.keyMap&&!!this.params.keyMap[i]&&!!this[this.params.keyMap[i]]){this[this.params.keyMap[i]].apply(this);return BX.PreventDefault(t)}};BX.CImageView.prototype._toggle_resize=function(){var t=this.params.resize;this.params.resize=this.params.resizeToggle;this.params.resizeToggle=t;if(this.params.resize!="WH"){this.params.lockScroll=true;this._lock_scroll()}else{this.params.lockScroll=false;this._unlock_scroll()}this.adjustSize();this.adjustPos()};BX.CImageView.prototype.adjustPos=function(){if(this.list[this._current].height>0&&this.list[this._current].width>0){this._adjustPosByImg()}else{if(!this.IMAGE_WRAP.style.height)this.IMAGE_WRAP.style.height="100px";if(!this.IMAGE_WRAP.style.width)this.IMAGE_WRAP.style.width="100px";setTimeout(BX.proxy(this._adjustPosByImg,this),250)}};BX.CImageView.prototype._adjustPosByImg=function(){if(this.bVisible){var t=BX.GetWindowSize(),i=parseInt((t.innerHeight-parseInt(this.IMAGE_WRAP.style.height)-2*this.params.minPadding)/2),e=parseInt((t.innerWidth-parseInt(this.IMAGE_WRAP.style.width)-2*this.params.minPadding)/2);if(!this.params.lockScroll&&t.innerWidth<t.scrollHeight)e-=20;if(i<this.params.minMargin)i=this.params.minMargin;if(e<this.params.minMargin+Math.min(70,this.PREV_LINK.offsetWidth))e=this.params.minMargin+Math.min(70,this.PREV_LINK.offsetWidth);if(this.params.showTitle&&!!this.list[this._current].title){i-=20}this.DIV.style.top=i+"px";this.DIV.style.left=e+"px"}};BX.CImageView.prototype.adjustSize=function(){var t=BX.GetWindowSize(),i=this.list[this._current];if(!!i.height&&!!i.width){if(!this.params.lockScroll&&t.innerWidth<t.scrollHeight)t.innerWidth-=20;t.innerWidth-=this.params.minMargin*2+this.params.minPadding*2+Math.min(140,this.PREV_LINK.offsetWidth+this.NEXT_LINK.offsetWidth);t.innerHeight-=this.params.minMargin*2+this.params.minPadding*2;if(this.params.showTitle&&!!this.list[this._current].title){t.innerHeight-=40}var e=i.height,s=i.width,r=[1];if(this.params.resize){if(this.params.resize.indexOf("W")>=0)r.push(t.innerWidth/s);if(this.params.resize.indexOf("H")>=0)r.push(t.innerHeight/e)}r=Math.min.apply(window,r);e*=r;s*=r;this.IMAGE_WRAP.style.height=parseInt(e)+"px";this.IMAGE_WRAP.style.width=parseInt(s)+"px";if(BX.browser.IsIE()){var h=parseInt(this.IMAGE_WRAP.style.height)+this.params.minPadding*2;this.PREV_LINK.style.height=this.NEXT_LINK.style.height=h+"px";this.PREV_LINK.firstChild.style.top=this.NEXT_LINK.firstChild.style.top=parseInt(h/2-20)+"px"}}};BX.CImageView.prototype._lock_scroll=function(){if(this.params.lockScroll)BX.addClass(document.body,"bx-images-viewer-lock-scroll")};BX.CImageView.prototype._unlock_scroll=function(){if(this.params.lockScroll)BX.removeClass(document.body,"bx-images-viewer-lock-scroll")};BX.CImageView.prototype._unhide=function(){this.bVisible=true;this.DIV.style.display="block";this.OVERLAY.style.display="block";this.PREV_LINK.style.display=this.list.length>1&&(this.params.cycle||this._current>0)?"block":"none";this.NEXT_LINK.style.display=this.list.length>1&&(this.params.cycle||this._current<this.list.length-1)?"block":"none";this.adjustPos();BX.unbind(document,"keydown",BX.proxy(this._keypress,this));BX.unbind(window,"resize",BX.proxy(this.adjustSize,this));BX.unbind(window,"resize",BX.proxy(this.adjustPos,this));BX.bind(document,"keydown",BX.proxy(this._keypress,this));BX.bind(window,"resize",BX.proxy(this.adjustSize,this));BX.bind(window,"resize",BX.proxy(this.adjustPos,this));this._lock_scroll()};BX.CImageView.prototype._hide=function(){this.bVisible=false;this.DIV.style.display="none";this.OVERLAY.style.display="none";BX.unbind(document,"keydown",BX.proxy(this._keypress,this));BX.unbind(window,"resize",BX.proxy(this.adjustSize,this));BX.unbind(window,"resize",BX.proxy(this.adjustPos,this));this._unlock_scroll();BX.onCustomEvent(this,"onImageViewClose",[this.list[this._current]])};BX.CImageView.prototype.add=function(t){this.list.push(t)};BX.CImageView.prototype.setList=function(t){this.list=[];this.list_preload=[];if(!!t&&BX.type.isArray(t)){for(var i=0;i<t.length;i++){this.add(t[i])}}if(this.bVisible){if(this.list.length>0)this.show();else this.close()}};BX.CImageView.prototype.show=function(t){var i=this._current;if(BX.type.isElementNode(t))t=t.getAttribute("src");if(typeof t=="object"&&(!!t.image||!!t.thumb))t=t.image||t.thumb;if(BX.type.isString(t)){for(var e=0;e<this.list.length;e++){if(this.list[e].image==t||this.list[e].thumb==t){i=e;break}}}t=this.list[i];if(!t)return;this._current=i;this._create();this.IMAGE.style.opacity=0;this.adjustSize();if(!this.list_preload[this._current]){BX.addClass(this.IMAGE_WRAP,"bx-images-viewer-wrap-loading");this.list_preload[this._current]=new Image;this.list_preload[this._current].bxloaded=false;this.list_preload[this._current].onload=this._get_image_onload();this.list_preload[this._current].src=t.image;BX.defer(function(){if(this.list_preload[this._current].width>0||this.list_preload[this._current].height>0){this.IMAGE.onload=null;this.IMAGE.style.opacity=1}},this)()}else if(this.list_preload[this._current].bxloaded){setTimeout(BX.delegate(this.list_preload[this._current].onload,this.list_preload[this._current]),350)}setTimeout(BX.proxy(this._check_title,this),300);this._unhide();BX.onCustomEvent(this,"onImageViewShow",[t])};BX.CImageView.prototype._check_title=function(){this.IMAGE_TITLE.innerHTML="";if(this.params.showTitle&&this.list[this._current].title||this.list[this._current].full){var t=0,i=0,e={style:{opacity:"1"},children:[]};if(this.params.showTitle&&this.list[this._current].title){e.children.push(BX.create("DIV",{props:{className:"bx-images-viewer-title-item"},text:this.list[this._current].title}));t+=35;i+=35}if(this.list[this._current].full){var s=[];if(this.list[this._current].full_height&&this.list[this._current].full_width){s.push(this.list[this._current].full_width+"x"+this.list[this._current].full_height)}if(this.list[this._current].full_size){s.push(this.list[this._current].full_size)}html='<a href="'+this.list[this._current].full+'" class="bx-images-viewer-full-link" target="_blank">'+BX.message("JS_CORE_IMAGE_FULL")+(s.length>0?" ("+s.join(", ")+")":"")+"</a>";e.children.push(BX.create("DIV",{props:{className:"bx-images-viewer-title-item bx-images-viewer-full"},html:html}));t+=35;i+=35}e.style.height=t+"px";e.style.bottom=-i+"px";BX.adjust(this.IMAGE_TITLE,e)}else{this.IMAGE_TITLE.style.opacity="0";this.IMAGE_TITLE.style.bottom="0";this.IMAGE_TITLE.style.height="0"}};BX.CImageView.prototype._get_image_onload=function(t){t=typeof t=="undefined"?this._current:t;return BX.delegate(function(){BX.proxy_context.bxloaded=true;if(t==this._current){var i=this.list[this._current];BX.removeClass(this.IMAGE_WRAP,"bx-images-viewer-wrap-loading");this.IMAGE.onload=function(){this.onload=null;this.style.opacity=1};this.IMAGE.src=BX.proxy_context.src;if(BX.proxy_context.width)i.width=BX.proxy_context.width;if(BX.proxy_context.height)i.height=BX.proxy_context.height;this.adjustSize();this.adjustPos();BX.defer(this._preload,this)()}BX.onCustomEvent(this,"onImageViewLoad",[this.list[t],t==this._current])},this)};BX.CImageView.prototype._preload=function(){if(this.params.preload>0){var t=Math.max(this._current-this.params.preload,this.params.cycle?-1e3:0),i=Math.min(this._current+this.params.preload,this.params.cycle?this.list.length+1e3:this.list.length-1);if(t<i){for(var e=i;e>=t;e--){var s=e;if(s<0)s+=this.list.length;else if(s>=this.list.length)s-=this.list.length;if(!this.list_preload[s]){this.list_preload[s]=new Image;this.list_preload[s].src=this.list[s].image;this.list_preload[s].onload=this._get_image_onload(s)}}}}};BX.CImageView.prototype.next=function(){if(this.list.length>1){this._current++;if(this._current>=this.list.length){if(!!this.params.cycle)this._current=0;else this._current--;BX.onCustomEvent(this,"onImageViewFinishList",[this.list[this._current],1])}this.show()}};BX.CImageView.prototype.prev=function(){if(this.list.length>1){this._current--;if(this._current<0){if(!!this.params.cycle)this._current=this.list.length-1;else this._current++;BX.onCustomEvent(this,"onImageViewFinishList",[this.list[this._current],-1])}this.show()}};BX.CImageView.prototype.close=function(){this._hide()}})(window);
//# sourceMappingURL=core_image.map.js